Clang++

您所在的位置:网站首页 python3 struct模块 Clang++

Clang++

2023-03-27 04:20| 来源: 网络整理| 查看: 265

在下面的代码中,我尝试使用CRTP来使用Parent类中Child类的静态成员"value".当编译使用g ++ 5.2.1与"-pedantic"标志的代码,我能够编译预期,并且在执行双方c.print_value();并Child::print_value();打印出4.

#include template struct Parent { static const int value = DE::value; static void print_value () { std::cout struct Child : Parent > { static const int value = N; }; int main () { Child c; c.print_value(); Child::print_value(); }

但是,当使用clang ++ 3.7编译相同的代码时,我遇到了编译失败.

crtp_clang_error.cpp:9:32: error: no member named 'value' in 'Child' static const int value = DE::value; ~~~~^ crtp_clang_error.cpp:27:16: note: in instantiation of template class 'Parent >' requested here struct Child : Parent > ^ crtp_clang_error.cpp:38:16: note: in instantiation of template class 'Child' requested here Child c; ^ crtp_clang_error.cpp:40:3: error: no member named 'print_value' in 'Child'; did you mean 'Parent >::print_value'? Child::print_value(); ^~~~~~~~~~~~~~~~~~~~~~~~~ Parent >::print_value crtp_clang_error.cpp:11:15: note: 'Parent >::print_value' declared here static void print_value ()

我不确定这是一个Clang ++ bug还是GCC hack.非常感谢一些见解.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3